package cn.gson.crm.controller.apply;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.ApplyDao;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ApplyManagerServlet
 */
@WebServlet("/apply/manager")
public class ApplyManagerServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private ApplyDao ad = new ApplyDao();

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String applyId = request.getParameter("applyId");
		String id = request.getParameter("id");
		String custId = request.getParameter("custId");
		int ids = Integer.parseInt(id);
		ad.updateApplyByApplyIdAndStatusId(Integer.parseInt(applyId), ids);
		if(ids == 4){
			ad.updateCustomerStatusByCustId(Integer.parseInt(custId));
		}
		redirect("search/apply");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
